#!/usr/bin/env python
#coding:utf8
import sys
from socket import *
class Test():
    serverHost = '127.0.0.1'
    serverPort = 50007
    socketobj = ''
    def show(self):
        print 'hello %s' %sys.argv[1]
    def initsocket(self):
        self.socketobj = socket(AF_INET,SOCK_STREAM)
        self.socketobj.connect((self.serverHost,self.serverPort))
    def sendsocket(self):
        if len(sys.argv)<=1:
            print 'message wasn\' defined'
        else:
            message = sys.argv[1]
            if self.socketobj:
                self.socketobj.send(message)
            else:
                self.initsocket()
                self.socketobj.send(message)
            data = self.socketobj.recv(1024)
            print('click received:',data)
        

testobj = Test()
testobj.sendsocket()